<template>
  <div class="loading-box">
    <div class="loading-content">
      <template v-if="emptyText && emptyText.indexOf('无') < 0">
        <div class="bar"></div>
      </template>
      <template v-else>
        <p class="emptyText">{{ emptyText }}</p>
      </template>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    emptyText: {
      type: String,
      default: "",
    },
  },
};
</script>

<style lang="scss" scoped>
.loading-box {
  position: relative;
  width: 100%;
  height: 1.5rem;
  // height: 3.6em;
  text-align: center;
  .loading-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    .bar {
      position: relative;
      display: inline-block;
      width: 1em;
      // height: 3.6em;
      height: 1.5rem;
      border-radius: 2px;
      // margin-top: 3em;
      margin-top: 0.4rem;
      box-shadow: 0 0 0 0 $color13;
      background-color: $color13;
      animation: load 1s infinite ease-in-out;
      animation-delay: -0.16s;
      &:before {
        position: absolute;
        top: 0;
        left: -1em;
        width: 1em;
        height: 3.6em;
        border-radius: 2px;
        margin-left: -0.5em;
        box-shadow: 0 0 0 0 $color13;
        content: "";
        background-color: $color13;
        animation: load 1s infinite ease-in-out;
        animation-delay: -0.32s;
      }
      &:after {
        position: absolute;
        top: 0;
        right: -1em;
        width: 1em;
        height: 3.6em;
        border-radius: 2px;
        margin-right: -0.5em;
        box-shadow: 0 0 0 0 $color13;
        content: "";
        background-color: $color13;
        animation: load 1s infinite ease-in-out;
      }
    }
    .emptyText {
      font-size: 0.14rem;
      color: $color52;
    }
  }
}
@keyframes load {
  0%,
  80%,
  100% {
    box-shadow: 0 0 0 0 $color13;
    height: 3.6em;
  }
  40% {
    box-shadow: 0 -1em 0 0 $color13;
    height: 4.6em;
  }
}
</style>
